package com.example.multithread;

class MyThread1 extends Thread {
    private String name;

    public MyThread1(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(""+this.name+" 线程执行，当前的循环次数为: " + i);
        }
    }
}
public class MyThread {
    public static void main(String[] args) {
        // 错误的多线程调用
        MyThread1 myThread1 = new MyThread1("线程A");
        MyThread1 myThread2 = new MyThread1("线程B");
        MyThread1 myThread3 = new MyThread1("线程C");
        myThread1.run();
        myThread2.run();
        myThread3.run();
        // 错误的多线程调用
        System.out.println("================================");
        // 正确的多线程调用
        MyThread1 myThread4 = new MyThread1("线程D");
        MyThread1 myThread5 = new MyThread1("线程E");
        MyThread1 myThread6 = new MyThread1("线程F");
        myThread4.start();
        myThread5.start();
        myThread6.start();
    }
}
